package com.mallcloud.mall.app.api.entity.vo;

import com.alibaba.fastjson.annotation.JSONField;
import com.mallcloud.mall.common.core.constant.enums.app.WxPayEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

@ApiModel(value = "WxPay3NotifyDataVO", description = "微信3统一支付")
@Data
public class WxPay3NotifyDataVO implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("商户号")
	@JSONField(name = "mchid")
    private String mchId;

	@ApiModelProperty("应用ID")
	@JSONField(name = "appid")
    private String appId;

	@ApiModelProperty("商户订单号")
	@JSONField(name = "out_trade_no")
    private String outTradeNo;

	@ApiModelProperty("微信支付订单号")
	@JSONField(name = "transaction_id")
    private String transactionId;

	/**
	 * {@link WxPayEnum.TradeTypeEnum}
	 */
	@ApiModelProperty("交易类型")
	@JSONField(name = "trade_type")
    private String tradeType;

	/**
	 * {@link WxPayEnum.TradeStateEnum}
	 */
	@ApiModelProperty("交易状态")
	@JSONField(name = "trade_state")
    private String tradeState;

	public Boolean isSuccess(){
		return WxPayEnum.TradeStateEnum.SUCCESS.name().equals(this.tradeState);
	}

	@ApiModelProperty("交易状态描述")
	@JSONField(name = "trade_state_desc")
    private String tradeStateDesc;

	@ApiModelProperty("付款银行")
	@JSONField(name = "bank_type")
    private String bankType;

	@ApiModelProperty("附加数据")
    private String attach;

	@ApiModelProperty("支付完成时间")
	@JSONField(name = "success_time")
    private String successTime;

	@ApiModelProperty("支付者")
    private Payer payer;

	@ApiModelProperty("订单金额")
    private Amount amount;

	@ApiModelProperty("场景信息")
	@JSONField(name = "scene_info")
    private SceneInfo sceneInfo;

	@ApiModelProperty("优惠功能")
	@JSONField(name = "promotion_detail")
    private List<PromotionDetail> promotionDetail;

	@ApiModel(value = "Payer", description = "微信3统一支付-支付者")
    @Data
    public static class Payer implements Serializable {
		private static final long serialVersionUID = 1L;

		@ApiModelProperty("用户标识")
		@JSONField(name = "openid")
        private String openId;
    }

	@ApiModel(value = "Amount", description = "微信3统一支付-订单金额")
	@Data
	public static class Amount implements Serializable {
		private static final long serialVersionUID = 1L;

		@ApiModelProperty("总金额")
		private Long total;//分

		@ApiModelProperty("用户支付金额")
		@JSONField(name = "payer_total")
		private Long payerTotal;//分

		@ApiModelProperty("货币类型")
		private String currency;

		@ApiModelProperty("用户支付币种")
		@JSONField(name = "payer_currency")
		private String payerCurrency;
	}

	@ApiModel(value = "SceneInfo", description = "微信3统一支付-场景信息")
    @Data
    public static class SceneInfo implements Serializable {
		private static final long serialVersionUID = 1L;

		@ApiModelProperty("商户端设备号")
		@JSONField(name = "device_id")
        private String deviceId;
    }

	@ApiModel(value = "PromotionDetail", description = "微信3统一支付-优惠功能")
	@Data
	public static class PromotionDetail implements Serializable {
		private static final long serialVersionUID = 1L;

		@ApiModelProperty("券ID")
		@JSONField(name = "couponId")
		private String coupon_id;

		@ApiModelProperty("优惠名称")
		@JSONField(name = "name")
		private String name;

		@ApiModelProperty("优惠范围")
		@JSONField(name = "scope")
		private String scope;

		@ApiModelProperty("优惠类型")
		@JSONField(name = "type")
		private String type;

		@ApiModelProperty("优惠券面额")
		@JSONField(name = "amount")
		private BigDecimal amount;

		@ApiModelProperty("活动ID")
		@JSONField(name = "stock_id")
		private String stockId;

		@ApiModelProperty("微信出资")
		@JSONField(name = "wechatpay_contribute")
		private BigDecimal wechatpayContribute;

		@ApiModelProperty("商户出资")
		@JSONField(name = "merchant_contribute")
		private BigDecimal merchantContribute;

		@ApiModelProperty("其他出资")
		@JSONField(name = "other_contribute")
		private BigDecimal otherContribute;

		@ApiModelProperty("优惠币种")
		@JSONField(name = "currency")
		private String currency;

		@ApiModelProperty("单品列表信息")
		@JSONField(name = "goods_detail")
		private GoodsDetail goodsDetail;
	}

	@ApiModel(value = "GoodsDetail", description = "微信3统一支付-单品列表信息")
	@Data
	public static class GoodsDetail implements Serializable {
		private static final long serialVersionUID = 1L;

		@ApiModelProperty("商品编码")
		@JSONField(name = "goods_id")
		private String goodsId;

		@ApiModelProperty("商品数量")
		@JSONField(name = "quantity")
		private Integer quantity;

		@ApiModelProperty("商品单价(分)")
		@JSONField(name = "unit_price")
		private BigDecimal unitPrice;

		@ApiModelProperty("商品优惠金额")
		@JSONField(name = "discount_amount")
		private BigDecimal discountAmount;

		@ApiModelProperty("商品备注")
		@JSONField(name = "goods_remark")
		private String goodsRemark;
	}
}
